#!/usr/bin/env bash -e

# Note: use lowercase names for the Docker images
DOCKER_IMAGE="azureiotpcs/pcs-config-dotnet"

APP_HOME="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && cd .. && pwd )/"
source "$APP_HOME/scripts/.functions.sh"

run_container() {
    check_dependency_docker

    $APP_HOME/scripts/env-vars-check

    echo "Starting Config service ..."
    docker run -it -p 9005:9005 \
        -e PCS_AUTH_WEBSERVICE_URL \
        -e PCS_STORAGEADAPTER_WEBSERVICE_URL \
        -e PCS_DEVICESIMULATION_WEBSERVICE_URL \
        -e PCS_TELEMETRY_WEBSERVICE_URL \
        -e PCS_SOLUTION_TYPE \
        -e PCS_AZUREMAPS_KEY \
        -e PCS_AUTH_ISSUER \
        -e PCS_AUTH_AUDIENCE \
        -e PCS_AUTH_REQUIRED \
        -e PCS_CORS_WHITELIST \
        -e PCS_APPLICATION_SECRET \
        -e PCS_OFFICE365_CONNECTION_URL \
        -e PCS_SOLUTION_NAME \
        -e PCS_SUBSCRIPTION_ID \
        -e PCS_ARM_ENDPOINT_URL \
        -e PCS_SEED_TEMPLATE \
        "$DOCKER_IMAGE:testing"
}

run_container
